package com.plum.admin.common.exception;

import com.plum.admin.common.util.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * TODO
 *
 * @author 子丶沫
 * @version 1.0
 * @date 2021/8/13 16:59
 */
@Slf4j
@RestControllerAdvice
public class RestExceptionHandler {

    @ExceptionHandler(CodeValidateException.class)
    @ResponseStatus(value = HttpStatus.OK)
    public R errorValidateHandler(CodeValidateException e){
        return R.error(e.getMessage());
    }

    @ExceptionHandler(BaseException.class)
    @ResponseStatus(value = HttpStatus.OK)
    public R baseExceptionHandler(BaseException e){
        return R.error(e.getMessage());
    }
}
